package vip.specimen.system.datasource.validation.implement;

import vip.specimen.system.common.enums.SaveMethodEnum;
import vip.specimen.system.datasource.validation.annotation.SaveEnum;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * *@Author: 余浪人
 * *@Date：2021/3/9 9:02
 * *@Email:yulangren520@Gmail.com
 * *@QQ:1368419640
 **/
public class SaveValidatorImp implements ConstraintValidator<SaveEnum, String> {

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        try {
            SaveMethodEnum.valueOf(s);
        } catch (IllegalArgumentException e) {
            return false;
        }
        return true;

    }
}
